<?php
require  "ConnectMysql.php";

$sql = connectDB();

$user = $_POST['user'];
$content = $_POST['content'];
$email = $_POST['email'];

if (strlen($content) >= 1000 || strlen($content) === 0) {
    exit("内容不合法");
}

if (strlen($user) >= 20 || strlen($user) === 0) {
    exit("署名不合法");
}

if (strlen($email) >= 30 || strlen($email) === 0) {
    exit("联系方式不合法");
}


$code = $sql->prepare('INSERT INTO `message`(`user`,`content`,`email`,`created_at`) VALUES (?,?,?,NOW())');

if ($code->error) {
    exit($code->error);
}
if ($sql->error) {
    exit($sql->error);
}

$code->bind_param("sss",$user,$content,$email);
$code->execute();
if ($code->error) {
    echo $code->error;
}
echo 1;
